﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Barry.Slide.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;

namespace Barry.Slide.Drivers
{
    public class SlideDriver : ContentPartDriver<SlidePart>
    {
        protected override DriverResult Display(SlidePart part, string displayType, dynamic shapeHelper) {
            return ContentShape("Parts_Slide", () => shapeHelper.Parts_Slide(
                Latitude: part.Latitude,
                Longitude: part.Longitude,
                URLists: part.URLLists
           ));
        }
        protected override DriverResult Editor(
                   SlidePart part, dynamic shapeHelper)
        {

            return ContentShape("Parts_Slide_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/Slide",
                    Model: part,
                    Prefix: Prefix));
        }
        //POST
        protected override DriverResult Editor(
            SlidePart part, IUpdateModel updater, dynamic shapeHelper)
        {

            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}